package com.dwb.service;

import com.dwb.entity.SSlide;
import com.dwb.mappers.SSlideMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @Author manke
 * @Date 2020/6/27 17:37
 * @Version 0.0.1
 */
@Service
public class SSlideService {
    @Autowired
    private SSlideMapper sSlideMapper;


    public PageInfo<SSlide> getList(Map<String, String> parameters) {
        PageHelper.startPage(Integer.parseInt(parameters.get("pageNum") == null ? "" : "1"),
                Integer.parseInt(parameters.get("pageSize") == null ? "" : "10"));
        List<SSlide> sSlides = sSlideMapper.selectAll();
        return new PageInfo<>(sSlides);


    }

    public void add(SSlide sSlide) {

        sSlideMapper.insert(sSlide);
    }

    public void update(SSlide sSlide) {
        sSlideMapper.updateByPrimaryKeySelective(sSlide);
    }

    public void delete(Map<String, String> parameters) {

        sSlideMapper.deleteByPrimaryKey(parameters.get("id"));
    }

    public SSlide getInfo(Map<String, String> parameters) {
        return sSlideMapper.selectByPrimaryKey(parameters.get("id"));

    }
}
